<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="com.mobilottery.server.GameParticipation"%>
<%@page import="java.util.Set"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/pages/template/page-begin.jspf" %>
<%
	_pageTitle = "My Games"; 
	_pageId = "mygames"; 
	_mainPageId = "mygames"; 
%>
<%@ include file="/pages/template/head-begin.jspf" %>
<%@ include file="/pages/template/head-end.jspf" %>

<body>
	<%@ include file="/pages/template/content-begin.jspf" %>
	<%@ include file="/pages/template/bar-left.jspf" %>
	<%@ include file="/pages/template/bar-right.jspf" %>
	<%@ include file="/pages/template/checklogin.jspf" %>
	
	<div id="content">
		<h3>Current Games</h3>
		<hr />
		<%
		//list few last games
		List<GameParticipation> games = GameProvider.getInstance().getGameManager().getUserActiveParticipations(sessionUser.getId());
		if(games.size()>0)
		{
			for(GameParticipation gameParticipation : games)
			{
				Game game = gameParticipation.getGame();
			%>
			<div class="featurebox_center" style="">
				<a href="/pages/playgame.jsp?gameId=<%=game.getId()%>" style="float:right">Play More</a>
				 #<%=game.getId()%> <%=game.getDescription()%>  <br />
				 Transaction <%=gameParticipation.getTransactionId()%><br />
				 Prize: <%=ValidationForm.PRICE_FORMAT.format(game.getMaxPrize())%> <br />
				 Closes: <%= ValidationForm.DATE_FORMAT.format(game.getCloseDate()) %> <br />  
				 My Numbers: <%= gameParticipation.getGuessedNumbersRaw() %> <br />  
			</div>
			<%
			}
		}
		else 
		{
		%>
		No active games
		<%
		}
		%>
		<br /><br />
	
	
		<h3>Played Games</h3>
		<hr />
		<%
		//list few last games
		List<GameParticipation> pastPlayedGames = GameProvider.getInstance().getGameManager().getUserPlayedParticipations(sessionUser.getId());
		if(pastPlayedGames.size()>0)
		{
			for(GameParticipation gameParticipation : pastPlayedGames)
			{
				Game game = gameParticipation.getGame();
				Set<Long> winningNumbers = game.getWiningNumbers();
			%>
			<div class="featurebox_center" style="">
				 #<%=game.getId()%> <%=game.getDescription()%>  <br />
				 Transaction <%=gameParticipation.getTransactionId()%><br />
				 Won amount: <%=ValidationForm.PRICE_FORMAT.format(gameParticipation.getWinningAmount())%> <br />
				 Closes: <%= ValidationForm.DATE_FORMAT.format(game.getCloseDate()) %> <br />  
				 My Numbers: <% for(Long guessedNumber : gameParticipation.getGuessedNumbers()){ %>
				 <span 
				 	<%=winningNumbers.contains(guessedNumber) ? "style='color:red;'" : "" %>
				 	>
				 	<%=guessedNumber%>
				 </span> 
				 <%} %> 
				 <br />  
				 Winning Numbers: <%=winningNumbers%> <br />  
			</div>
			<%
			}
		}
		else 
		{
		%>
		No active games
		<%
		}
		%>	
				
	</div>


	<jsp:include page="/pages/template/content-end.jspf" />
	
</body>
</html>
